package com.ljc.api;

import com.ljc.auth.AuthRole;
import com.ljc.auth.AuthRoleElementOperation;
import com.ljc.auth.AuthRoleMenu;
import com.ljc.interfaces.AuthRoleApi;
import com.ljc.mapper.AuthRoleElementOperationMapper;
import com.ljc.mapper.AuthRoleMapper;
import com.ljc.mapper.AuthRoleMenuMapper;
import org.apache.dubbo.config.annotation.DubboService;

import javax.annotation.Resource;
import java.util.List;
import java.util.Set;

@DubboService
public class AuthRoleApiImpl implements AuthRoleApi {
    @Resource
    private AuthRoleMapper authRoleMapper;
    @Resource
    private AuthRoleElementOperationMapper authRoleElementOperationMapper;
    @Resource
    private AuthRoleMenuMapper authRoleMenuMapper;

    /**
     * 通过角色id集合查询拥有的页面元素操作权限
     */
    @Override
    public List<AuthRoleElementOperation> getRoleElementOperationsByRoleIds(Set<Long> roleIdSet) {
        return authRoleElementOperationMapper.getRoleElementOperationsByRoleIds(roleIdSet);
    }

    /**
     * 通过角色id查询拥有的页面菜单权限
     */
    @Override
    public List<AuthRoleMenu> getAuthRoleMenus(Set<Long> roleIdSet) {
        return authRoleMenuMapper.getAuthRoleMenus(roleIdSet);
    }

    /**
     * 根据角色等级获得角色编号
     */
    @Override
    public AuthRole getRoleByCode(String code) {
        return authRoleMapper.getRoleByCode(code);
    }
}
